module.exports = (app) => {
  const mongoose = app.mongoose

  class Schema extends mongoose.Schema {
    constructor() {
      const args = arguments

      super(
        {
          isDelete: { type: Boolean, default: false }, // 是否删除
          isOpen: { type: Boolean, default: false }, // 是否上线
          ...args[0],
        },
        {
          timestamps: true,
          toJSON: { virtuals: true }, // json中 显示虚拟对象
          toObject: { virtuals: true }, // console.log 中显示虚拟对象
          ...args[1],
        }
      )
    }
  }

  return Schema
}
